package opdracht04;

public class Temperature {
   private long value;
   
   private static final long FREEZING_TEMPERATURE = 0L;
   private static final long BOILING_TEMPERATURE = 10000L;
   
   public Temperature(float value) {
      System.out.println("test");
      this.value = round(value);
   }
   
   public float getValue() {
      return value/100F;
   }
   
   public void setValue(float value) {
      this.value = round(value);
   }
      
   public boolean isFreezing() {
      return value <= FREEZING_TEMPERATURE;
   }
   
   public boolean isBoiling() {
      return value >= BOILING_TEMPERATURE;
   }
   
   public boolean equals(Object o) {
      if( o == null) return false;
      if( ! (o instanceof Temperature)) return false;
      return ((Temperature) o).value == this.value;
   }
   
   public int hashCode() {
      return (int) value;
   }
   
   private long round(float value) {
      return Math.round(value * 100);
   }
}
